from datetime import datetime
from typing import Optional, List
from pydantic import BaseModel


class CreateFlowerTypeRequest(BaseModel):
    name: str
    created_on: Optional[datetime] = None
    created_by: Optional[int] = None


class UpdateFlowerTypeRequest(BaseModel):
    id: int
    name: str
    updated_on: Optional[datetime] = None
    updated_by: Optional[int] = None


class FlowerTypeModel(BaseModel):
    id: int
    created_on: Optional[datetime] = None
    created_by: Optional[int] = None
    updated_on: Optional[datetime] = None
    updated_by: Optional[int] = None
    name: str
    count: Optional[int] = None

    class Config:
        from_attributes = True


class FlowerTypePagination(BaseModel):
    page: int
    page_size: int
    total: int
    data: List[FlowerTypeModel]


class CreateFlowerRequest(BaseModel):
    name: str
    description: Optional[str] = None
    created_on: Optional[datetime] = None
    created_by: Optional[int] = None
    images: Optional[List[str]] = []
    original_price: float
    price: float
    receiver: Optional[int] = None
    material: Optional[int] = None
    size: Optional[int] = None
    type: int
    occasion: Optional[int] = None
    tags: Optional[List[str]] = []
    status: Optional[int] = 1
    presale: Optional[bool] = False
    presale_start_date: Optional[datetime] = None
    presale_end_date: Optional[datetime] = None
    presale_delivery_start_date: Optional[datetime] = None
    presale_delivery_end_date: Optional[datetime] = None


class UpdateFlowerRequest(CreateFlowerRequest):
    id: int
    updated_on: Optional[datetime] = None
    updated_by: Optional[int] = None


class UpdateFlowerStatusRequest(BaseModel):
    id: int
    updated_on: Optional[datetime] = None
    updated_by: Optional[int] = None
    status: int


class TakeDownFlowerRequest(BaseModel):
    id: int
    updated_on: Optional[datetime] = None
    updated_by: Optional[int] = None


class FlowerModel(BaseModel):
    id: int
    created_on: Optional[datetime] = None
    created_by: Optional[int] = None
    updated_on: Optional[datetime] = None
    updated_by: Optional[int] = None
    status: Optional[int] = 1
    name: str
    description: Optional[str] = None
    images: Optional[List[str]] = []
    original_price: float
    price: float
    receiver: Optional[int] = None
    material: Optional[int] = None
    size: Optional[int] = None
    type: int
    occasion: Optional[int] = None
    tags: Optional[List[str]] = []
    sales_count: Optional[int] = 0
    views_count: Optional[int] = 0
    presale: Optional[bool] = False
    presale_start_date: Optional[datetime] = None
    presale_end_date: Optional[datetime] = None
    presale_delivery_start_date: Optional[datetime] = None
    presale_delivery_end_date: Optional[datetime] = None

    class Config:
        from_attributes = True


class FlowerOption(BaseModel):
    id: int
    name: str
    images: Optional[List[str]] = []
    original_price: float
    price: float
    receiver: int
    material: int
    size: int
    type: int
    occasion: Optional[int] = None
    tags: Optional[List[str]] = []

    class Config:
        from_attributes = True


class FlowerPagination(BaseModel):
    page: int
    page_size: int
    total: int
    data: List[FlowerModel]


class DeleteFlowerRequest(BaseModel):
    id: int
    updated_on: Optional[datetime] = None
    updated_by: Optional[int] = None
